﻿using System;
using System.ComponentModel;
using System.Windows.Media.Imaging;
using Blackbird.Core.Editable;
using Blackbird.Core.Editable.Frames;
using Blackbird.Studio.Mvvm;
using Microsoft.Win32;

namespace Blackbird.Studio.ViewModel.EntityViewModels
{
    public class EditableFrameViewModel : EntityViewModel<EditableFrame>
    {
        public EditableFrameViewModel(EditableFrame model)
            : base(model)
        {
            SelectFrameCommand = new RelayCommand(SelectFrame);
        }

        public override EntityType EntityType
        {
            get { return EntityType.Frame; }
        }

        public RelayCommand SelectFrameCommand { get; set; }
        private void SelectFrame(object param)
        {
            var dialog = new OpenFileDialog();
            var result = dialog.ShowDialog();
            if (result.Value)
            {
                var image = new BitmapImage(new Uri(dialog.FileName));
                Model.BitmapSource = image;
            }            
        }
    }
}